<template>
    <h1>计数器2: {{ count1 }}</h1>
    <button @click="increment(5)">增加</button>
</template>

<script>
import {mapState} from "vuex";

export default {
    name: 'HelloWorld2',
    props: {
        msg: String
    },
    data() {
        return {
            count: 0
        }
    },
    methods: {
        increment(step) {
            this.$store.commit({
                type: "increment", step: step
            })
        }
    },
    computed: mapState({
        count1: "count",
        count2(state) {
            return state.count
        }
    })
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
    margin: 40px 0 0;
}

ul {
    list-style-type: none;
    padding: 0;
}

li {
    display: inline-block;
    margin: 0 10px;
}

a {
    color: #42b983;
}
</style>
